package com.action.sanction;

import java.sql.SQLException;
import java.util.ArrayList;

import com.db.member.MemInfoVO;
import com.db.member.MemberManager;
import com.db.sancdoc.DocParamVO;
import com.db.sancdoc.VTDocManager;
import com.db.sancdoc.VTDocVO;
import com.opensymphony.xwork2.ActionContext;

public class DeptDocAction {
	private int memno;
	private MemInfoVO vo = new MemInfoVO();
	private ArrayList<VTDocVO> list = new ArrayList<VTDocVO>();

	private int doccount;
	private int totalpage;
	private int curpage;
	private DocParamVO paramVo = new DocParamVO();

	public int getCurpage() {
		return curpage;
	}

	public void setCurpage(int curpage) {
		this.curpage = curpage;
	}

	public int getDoccount() {
		return doccount;
	}

	public int getTotalpage() {
		return totalpage;
	}

	public ArrayList<VTDocVO> getList() {
		return list;
	}

	public void setMemno(int memno) {
		this.memno = memno;
	}

	public MemInfoVO getVo() {
		return vo;
	}

	public String execute() throws Exception {
		System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
memno = Integer.parseInt((String) ActionContext.getContext().getSession().get("memno"));//////////////////////////////////////////////////

		System.out.println(memno);

		
		vo = MemberManager.meminfoData(memno);

		int deptno = vo.getDeptno();

		System.out.println(deptno);

paramVo = getDocParam(deptno, curpage);
		list = VTDocManager.deptDocList(paramVo);

		System.out.println(list.size() + "aaa");

		
		doccount = VTDocManager.deptDocCount(deptno);
		totalpage = ((doccount-1) / 10) + 1;		
		
		
		return "success";
	}
	
	public DocParamVO getDocParam(int memno, int curpage) {
		System.out.println("curpage : "+curpage);		
				DocParamVO vo = new DocParamVO();
				vo.setMemno(memno);
				vo.setBegin((curpage * 10) - 9);
				vo.setEnd(curpage * 10);
				

				return vo;
			}
}
